package com.mzy.redis.utils;

import java.time.Duration;
import java.time.LocalTime;
import java.util.Random;

public class PhoneUtil {

    // 随机生成验证码的方法
    public static String getCode(int len) {
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < len; i++) {
            int rand = new Random().nextInt(10);
            code.append(rand);
        }
        return code.toString();
    }


    // 获取当天剩余秒数的方法
    public static long getTheLeftSeconds() {// 获取现在的时间
        LocalTime now = LocalTime.now();// 获取当日23点59分59秒的时间
        LocalTime end = LocalTime.of(23, 59, 59);
        // 获取end 与now相差的秒数
        long millis = Duration.between(now, end).toMillis() / 1000;
        return millis;
    }
}